// ============================== 导入依赖 ============================== //

import API from './API'
import UTIL from '@admin/views/Monitor/Elec/UTIL'

// ============================== 导出异步调用 ============================== //

export default {
  // —————————————————————————————— 信息 —————————————————————————————— //

  async remoteInfo({ state: { infoParam, MAP } }) {
    if (!infoParam.areaId) return {}

    const [today, yesterday] = await API.getInfo(infoParam, `查询${MAP.TITLE}`)
    return transInfo(today, yesterday)
  },
}

// ============================== 转换方法 ============================== //

const transInfo = (today, yesterday) => {
  return { dataList: [UTIL.transDataList(today), UTIL.transDataList(yesterday, -1)] }
}
